Skip to contentSkip to conversation

running application in user mode instead of root #yocto

DISCUSSION [email protected] 4 participants 5 messages Apr 27, 2021 – May 30, 2022

lore
Share & tools
lore
#0 lore raw

Hi All,

I am trying to run my application in less privilege mode instead of root user.
As i am new to Yocto build could you please some one suggest on how to configure my build environment to get user and run my application with the user privileges at startup.

Regards,
Vijay

#1 lore raw

Hello,

Quoted 3 lines

I am trying to run my application in less privilege mode instead of root user.
As i am new to Yocto build could you please some one suggest on how to configure my build environment to get user and run my application with the user privileges at startup.

You may be interested in ROOTLESS_X="1", to open a non-priviledged X11 session.

Quoted 5 lines

Regards,
Vijay

Signature · 2 lines
Yann Dirson <[email protected]>
Blade / Shadow -- http://shadow.tech
#2 lore raw
In reply to [email protected]

I'm new to yocto as well but what we do is in our own custom image:

inherit extrausers
EXTRA_USERS_PARAMS = " useradd nodered"

and then since we use systemd we've created our own service file that includes:

User=nodered

in the [service] block definition, so the executable is run using that user instead of root.

Extrausers docs are https://www.yoctoproject.org/docs/current/mega-manual/mega-manual.html#ref-classes-extrausers

An alternative you might look at is the useradd class https://git.yoctoproject.org/cgit.cgi/poky/tree/meta-skeleton/recipes-skeleton/useradd/useradd-example.bb which probably lets you set the users in your own recipe instead at image level